<%@page import="java.util.HashMap"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="org.w3c.dom.ls.LSInput"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.awt.List"%>
<%@page import="com.commonfunction.CommFunction"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib prefix="s" uri="/struts-tags"%>    
<!DOCTYPE html>
<html>
<head>
	<%HashMap datamap = (HashMap)session.getAttribute("datamap"); %>
    <title>weighingMachinEntry page</title>
    <link rel="stylesheet" href="css/jquery.mobile-1.3.2.min.css" />
	<link rel="stylesheet" href="css/weighingMachinEntry.css" />
    
    <style type="text/css">
    	.errors {
			background-color: #FFCCCC;
			border: 1px solid #CC0000;
			width: 400px;
			margin-bottom: 8px;
		}
		
		.errors li {
			list-style: none;
		}
    </style>
    <script type="text/javascript"  src="js/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="js/weighingMachinEntry.js"></script>
	<script type="text/javascript" src="js/jquery-barcode.min.js"></script>
	<script type="text/javascript">
	$(document).ready(function(){
		
		 $.mobile.ajaxEnabled = false;
	});
	var w;
	$(document).bind('pageshow',function(){
		 $.mobile.ajaxEnabled = false;
		setTimeout(function(){
			$("#barcodeGeneratorDiv").barcode('<%=((HashMap)session.getAttribute("datamap")).get("barcode")%>', "code39",{barWidth:2, barHeight:60,showHRI:false});
			$("#barcodeGeneratorDivForPrint").barcode('<%=((HashMap)session.getAttribute("datamap")).get("barcode")%>', "code39",{barWidth:2, barHeight:60,showHRI:false});
			$("#barcodeForProcess").barcode('<%=((HashMap)session.getAttribute("datamap")).get("barcode")%>', "code39",{barWidth:2, barHeight:60,showHRI:false});
			//setTimeout('printPage();', 1000);
			var rstNoValueVar = $("#RstNoValue").val();
			var vehicleNoValueVar = $("#VehicleNoValue").val();
			var customerNameVar = $("#cnamesearchField").val();
			var addressVar = $("#customerAddressValue").val();
			var commodityVar = $("#commodityValue").val();
			var brokerNamevar = $("#bnamesearchField").val();
			var poNoVar = $("#PONovalue").val();
			var noOfBagsVar = $("#BagsNoValue").val();
			var grossWeightVar = $("#grossWeight").val();
			var tareWeightVar = $("#tareWeight").val();
			var netWeightVar = $("#netWeight").val();
			var systemTimeVar = $("#systime").val();
			var systemDateVar = $("#SystemDate").val();
			var userIdVar = $("#UserID").val();
			var commisonAgentname=$("#commisionnamesearchField").val();
			
			
			//assigning value to new page for print
			
			$("#RstNoValueForPrint").text(rstNoValueVar);
			$("#VehicleNoValueForPrint").text(vehicleNoValueVar);
		    $("#customerNameForPrint").text(customerNameVar);
			$("#customerAddressValueForPrint").text(addressVar);
			$("#commodityValueForPrint").text(commodityVar);
			$("#brokerNameForPrint").text(brokerNamevar);
			$("#PONovalueForPrint").text(poNoVar);
			$("#BagsNoValueForPrint").text(noOfBagsVar);
			$("#grossWeightForPrint").text(grossWeightVar);
			$("#tareWeightForPrint").text(tareWeightVar);
			$("#netWeightForPrint").text(netWeightVar);
			$("#SystemTimeForPrint").text(systemTimeVar);
			$("#SystemDateForPrint").text(systemDateVar);
			$("#UserIDForPrint").text(userIdVar);
			$("#CommisionAgentForPrint").text(commisonAgentname);
			
			$(".tdClassForPrint").css({'text-align':'center'});
			
		
		},1000);
	});

	function printpage(){
		
		localStorage.isPrint = 'yes';
		
		w=window.open();
		var html= $("#printPageContentDiv").clone();
		html= $("#printPageContentDiv").html();
		$(w.document.body).html(html);
		printFinal();
	}
	
	function printFinal(){
		w.print();
		w.close();
		
	}
	
	function submitform(){
		if(localStorage.isPrint=='yes'){
			$('#weighingMachineForm').submit();
		}else{
			alert('Please take a printout first');
		}
		localStorage.isPrint='no';
	}
	</script>
	<script type="text/javascript" src="js/jquery.mobile-1.3.2.min.js"></script>
	 
</head>
<body>
	<div data-role="page" id="weighingMachinEntryPage">
		
		<div data-role="header" data-theme="b" id="weighingMachinEntryHeader">		
		<a href="menudisplay" data-role="buttun" data-icon="home">Menu</a>
		<h1>Weightments Entry Page</h1> 
		</div>
		<div align="center" data-role="content" id="weighingMachinEntryContent">
			<h1>PARVATI SOLVENTS EXTRACTION PVT LTD</h1>
			<h3>GUT NO.76, KHADGAON,TALUKA:BADNAPUR,DISTRICT:JALNA-431203,MAHARASHTRA,INDIA</h3>
		
			<s:if test="hasActionErrors()">
   			<div class="errors">
      			<s:actionerror/>
   			</div>
			</s:if>		
			
			<form id="weighingMachineForm" action="weightmachineSubmit" method="POST">
			<input type="hidden" name="barcode" value="<%=datamap.get("barcode") %>">
			<div id="tableContainer" class="tableContainer">
			<fieldset>
			<div id="tableDivRegionInfo1" class="tableDivRegion" data-role="fieldcontain">
				<table data-theme="c" border="1" width="80%">
					<tr>
						<td width="20%" class="tableContentTitle"><b>Rst No.</b></td>
						<td width="30%"><input name="rstno" id="RstNoValue" type="text" readonly="readonly" value="<%=datamap.get("rstno") %>" placeholder="Rst No." class="textBoxClass"/></td>
						<td width="20%" class="tableContentTitle"><b>Vehicle No.</b></td>
						<td width="30%"><input name="vehicleno" id="VehicleNoValue" type="text" readonly="readonly" value="<%=datamap.get("vehicleno") %>" placeholder="Vehicle No" class="textBoxClass"/></td>
					
					</tr>
					
					<tr>
						<td width="20%" class="tableContentTitle"><b>Customer Name</b></td>
						<td width="30%">
							<input name="custname" type="text" readonly="readonly" id="cnamesearchField" placeholder="Search" value="<%=datamap.get("custname") %>">
							<ul id="customersuggestions" data-role="listview" data-inset="true"></ul>
						</td>
						<td width="20%" class="tableContentTitle" rowspan="3"><b>Address</b></td>
						<td width="30%" rowspan="3"><textarea name="address" readonly="readonly" id="customerAddressValue" rows="4" class="textBoxClass"><%=datamap.get("address") %></textarea></td>
					
					</tr>
					<tr>
						<td width="20%" class="tableContentTitle"><b>Commodity</b></td>
						<td width="30%"><input name="commodity" id="commodityValue" type="text" readonly="readonly" value="<%=datamap.get("commodity") %>" placeholder="Commodity" class="textBoxClass"/></td>
						
					</tr>
					<tr>
						<td width="20%" class="tableContentTitle"><b>Broker Name</b></td>
						<td width="30%">
						<input name="brokername" type="text" readonly="readonly" id="bnamesearchField" placeholder="Search" value="<%=datamap.get("brokername")%>">
						<ul id="brockersuggestions" data-role="listview" data-inset="true"></ul>
						</td>
						
					</tr>
					<tr>
						<td width="20%" class="tableContentTitle"><b>P. O. No.</b></td>
						<td width="30%"><input name="ponum" id="PONovalue" type="text" readonly="readonly" value="<%=datamap.get("ponum") %>" placeholder="P. O. No." class="textBoxClass"/></td>
						<td width="20%" class="tableContentTitle"><b>No. Of Bags</b></td>
						<td width="30%"><input name="nobags" id="BagsNoValue" type="number" readonly="readonly" value="<%=datamap.get("nobags") %>" min="0" placeholder="No. of bags" class="textBoxClass"/></td>
					
					</tr>
					<tr>
						<td width="20%" class="tableContentTitle"><b>Commision Agent</b></td>
						<td width="30%">
						<input name="commisionname" type="text" readonly="readonly" id="commisionnamesearchField" placeholder="Search" value="<%=datamap.get("commisionname") %>">
						<ul id="commisionsuggestions" data-role="listview" data-inset="true"></ul>
						</td>
					</tr>
					
				</table>
				
			</div>
			
			<div id="tableDivRegionInfo2" class="tableDivRegion" data-role="fieldcontain">
			
				<table data-theme="c" border="1" width="80%">
				
					<tr>
						<td width="10%" class="tableContentTitle"><b>Gross Weight  :</b></td>
						<td width="13%"><input name="grossweight" id="grossWeight" type="text" readonly="readonly" value="<%=datamap.get("grossweight") %>" placeholder="Gross Weight" class="textBoxClass"/></td>
						<td width="34%" class="tableContentTitle"><b>Barcode</b></td>
						<td width="10%"class="tableContentTitle"><b>System Date :</b></td>
						<td width="13%"><input name="sysdate" id="SystemDate" readonly="readonly" value="<%=datamap.get("sysdate") %>" type="text" readonly="readonly" placeholder="dd/mm/yyyy" class="textBoxClass"/></td>
					</tr>
					<tr>
						<td width="10%" class="tableContentTitle"><b>Tare Weight  :</b></td>
						<td width="13%"><input name="tareweight" id="tareWeight" type="text" readonly="readonly" value="<%=datamap.get("tareweight") %>" placeholder="Tare Weight" class="textBoxClass"/></td>
						<td width="34%" rowspan="3"><div id="barcodeGeneratorDiv" class="barcodeGeneratorDiv"></div></td>
						<td width="10%" class="tableContentTitle" rowspan="2"><b>System time :</b></td>
						<td width="13%" rowspan="2"><input name="systime" id="systime" value="<%=datamap.get("systime") %>" type="text" readonly="readonly" placeholder="dd/mm/yyyy" class="textBoxClass"/></td>
					</tr>
					<tr>
						<td width="10%" class="tableContentTitle"><b>Net Weight  :</b></td>
						<td width="13%"><input name="netweight" id="netWeight" type="text" readonly="readonly" value="<%=datamap.get("netweight") %>" placeholder="Net Weight" class="textBoxClass"/></td>
					</tr>
					<tr>
						<td width="10%" class="tableContentTitle"><b>Operator Signature :</b></td>
						<td width="13%"></td>
						<td width="10%" class="tableContentTitle"><b>User ID :</b></td>
						<td width="13%"><input name="userid" id="UserID" type="text" readonly="readonly" class="textBoxClass" value="<%=datamap.get("userid") %>"/></td>
					</tr>
				
				</table>
			</div>
			</fieldset>
			</div>			
			<div id="submitPageDiv" class="submitPageDiv">
				<table>
				<tr><td class = "tableContentTitle"><button data-theme="a" type="button" onclick="submitform()" id="generateBarcodeButton">Submit</button><td><button data-theme="a" type="button" onclick="printpage()" id="generateBarcodeButton">Print</button></td></tr>
				</table>
			</div>
			
			</form>
		</div>
	</div>
	
	<div id="printPageContentDiv">
	
	<div id="tableContainerForPrint">
			<fieldset>
			<div id="headerForPrint" style="margin-right: auto; margin-left: auto;">
			<center><h2 style="margin-bottom: -3%;margin-top: -0.5%;">PARVATI SOLVENTS EXTRACTION PVT LTD</h2>
			<h6>GUT NO.76, KHADGAON,TALUKA: BADNAPUR,DISTRICT:JALNA-431203,MAHARASHTRA,INDIA</h6></center>
			<div>
			<div id="tableDivRegionInfo1forPrint" data-role="fieldcontain">
				<table data-theme="c" border="1" width="80%" style="border:none;border-collapse: collapse; margin-left: auto;margin-right: auto;">
					<tr>
						<td width="20%" class="tableContentTitle tdClassForPrint" style="text-align:center"><b>Rst No.</b></td>
						<td width="30%" class="tdClassForPrint"><div id="RstNoValueForPrint"></div></td>
						<td width="20%" class="tableContentTitle tdClassForPrint"><b>Vehicle No.</b></td>
						<td width="30%" class="tdClassForPrint"><div id="VehicleNoValueForPrint"></div></td>
					
					</tr>
					
					<tr>
						<td width="20%" class="tableContentTitle tdClassForPrint"><b>Customer Name</b></td>
						<td width="30%" class="tdClassForPrint"><div id="customerNameForPrint"></div></td>
						<td width="20%" class="tableContentTitle tdClassForPrint" rowspan="3"><b>Address</b></td>
						<td width="30%" rowspan="3" class="tdClassForPrint"><div id="customerAddressValueForPrint"></div></td>
					  
					</tr>
					<tr>
						<td width="20%" class="tableContentTitle tdClassForPrint"><b>Commodity</b></td>
						<td width="30%" class="tdClassForPrint"><div id="commodityValueForPrint"></div></td>
						
					</tr>
					<tr>
						<td width="20%" class="tableContentTitle tdClassForPrint"><b>Broker Name</b></td>
						<td width="30%" class="tdClassForPrint"><div id="brokerNameForPrint"></div></td>
						
					</tr>
					<tr>
						<td width="20%" class="tableContentTitle tdClassForPrint"><b>P. O. No.</b></td>
						<td width="30%" class="tdClassForPrint"><div id="PONovalueForPrint"></div></td>
						<td width="20%" class="tableContentTitle tdClassForPrint"><b>No. Of Bags</b></td>
						<td width="30%" class="tdClassForPrint"><div id="BagsNoValueForPrint"></div></td>
					 
					</tr>
					<tr>
						<td width="20%" class="tableContentTitle tdClassForPrint"><b>Commision Agent</b></td>
						<td width="30%" class="tdClassForPrint"><div id="CommisionAgentForPrint"></div></td>
						
					</tr>
				</table>
				
			</div>
			<br/>
			
			<div id="tableDivRegionInfo2" class="tableDivRegion" data-role="fieldcontain">
			
				<table data-theme="c" border="1" width="80%" style="border:none;border-collapse: collapse; margin-left: auto;margin-right: auto;">
				
					<tr>
						<td width="10%" class="tableContentTitle tdClassForPrint"><b>Gross Weight  :</b></td>
						<td width="13%" class="tdClassForPrint"><div id="grossWeightForPrint"></div></td>
						<td width="34%" class="tableContentTitle tdClassForPrint"><b>Barcode</b></td>
						<td width="10%" class="tableContentTitle tdClassForPrint"><b>System Date :</b></td>
						<td width="13%" class="tdClassForPrint"><div id="SystemDateForPrint"></div></td>
						
					</tr>
					<tr>
						<td width="10%" class="tableContentTitle tdClassForPrint"><b>Tare Weight  :</b></td>
						<td width="13%" class="tdClassForPrint"><div id="tareWeightForPrint"></div></td>
						<td width="34%" class="tdClassForPrint" rowspan="3"><div id="barcodeGeneratorDivForPrint" class="barcodeGeneratorDiv"></div></td>
						<td width="10%" class="tableContentTitle tdClassForPrint" rowspan="2"><b>System time :</b></td>
						<td width="13%" class="tdClassForPrint" rowspan="2"><div id="SystemTimeForPrint"></div></td>
						 
					</tr>
					<tr>
						<td width="10%" class="tableContentTitle tdClassForPrint"><b>Net Weight  :</b></td>
						<td width="13%" class="tdClassForPrint"><div id="netWeightForPrint"></div></td>
					</tr>
					<tr>
						<td width="10%" class="tableContentTitle tdClassForPrint"><b>Operator Signature :</b></td>
						<td width="13%" class="tdClassForPrint"><div id="OperatorSignForPrint"></div></td>
						<td width="10%" class="tableContentTitle tdClassForPrint"><b>User ID :</b></td>
						<td width="13%" class="tdClassForPrint"><div id="UserIDForPrint"></div></td>
					</tr>
				
				</table>
			</div>
			</fieldset>
			</div>
			<br/>
	<hr style="border-top: 2px dotted navy;"/>
	<br/><br/>
	<div id="barcodeForProcess" style="width:100%;  margin:0 auto;"></div>
	</div>
	
	
	
</body>
</html>